package com.heima.feigns;

import com.heima.config.HeimaFeignAutoConfiguration;
import com.heima.feigns.fallback.ArticleFeignFallback;
import com.heima.model.article.pojos.ApArticle;
import com.heima.model.article.pojos.ApAuthor;
import com.heima.model.article.vos.SearchArticleVO;
import com.heima.model.common.dtos.ResponseResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author mrchen
 * @date 2022/4/22 15:48
 */
@FeignClient(value = "leadnews-article",fallbackFactory = ArticleFeignFallback.class,configuration = HeimaFeignAutoConfiguration.class)
public interface ArticleFeign {

    @GetMapping("/api/v1/author/findByUserId/{userId}")
    public ResponseResult<ApAuthor> findByUserId(@PathVariable("userId") Integer userId);

    @PostMapping("/api/v1/author/save")
    public ResponseResult save(@RequestBody ApAuthor apAuthor);

    @GetMapping("/api/v1/article/{id}")
    ResponseResult<SearchArticleVO> findArticle(@PathVariable("id") Long id);

    @GetMapping("/api/v1/author/findByWmUserId/{wmUserId}")
    public ResponseResult<ApAuthor> findByWmUserId(@PathVariable("wmUserId") Integer wmUserId);

    @PostMapping("/api/v1/article/articleByAuthorId")
    public ResponseResult<List<ApArticle>> articleByAuthorId(@RequestParam String authorId);
}
